package com.zkteco.springdatajpademo.dao;

import com.zkteco.springdatajpademo.pojo.Customer;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

public interface CustomerDao extends JpaRepository<Customer, Long>, JpaSpecificationExecutor<Customer> {
    /**
     * jpql查询测试
     */
    @Query(value = "from Customer where custName = ?1")
    public Customer findJpql(String custName);

    @Query(value = "from Customer where custName= ?1 and custId = ?2")
    public Customer findCustomerByCustNameAndAndCustId(String name, Long id);

    @Query(value = "update Customer set custSource = ?1 where custId = ?2")
    @Modifying
    public void update(String source, Long id);

    @Query(value = "select * from cst_customer",nativeQuery = true)
    public List<Customer> findAll();
}
